﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace com.cgWorkstudio.BIMP.Library {
    public static class RoundFormPainter {
        public static void Paint(Form sender,PaintEventArgs e) {
            List<Point> list = new List<Point>();
            int width = sender.Width;
            int height = sender.Height;

            //左上
            list.Add(new Point(0,6));
            list.Add(new Point(1,6));
            list.Add(new Point(1,3));
            list.Add(new Point(2,3));
            list.Add(new Point(2,2));
            list.Add(new Point(3,2));
            list.Add(new Point(3,1));
            list.Add(new Point(6,1));
            list.Add(new Point(6,0));
            //右上
            list.Add(new Point(width - 6,0));
            list.Add(new Point(width - 6,1));
            list.Add(new Point(width - 3,1));
            list.Add(new Point(width - 3,2));
            list.Add(new Point(width - 2,2));
            list.Add(new Point(width - 2,3));
            list.Add(new Point(width - 1,3));
            list.Add(new Point(width - 1,6));
            list.Add(new Point(width - 0,6));
            //右下
            list.Add(new Point(width - 0,height - 6));
            list.Add(new Point(width - 1,height - 6));
            list.Add(new Point(width - 1,height - 3));
            list.Add(new Point(width - 2,height - 3));
            list.Add(new Point(width - 2,height - 2));
            list.Add(new Point(width - 3,height - 2));
            list.Add(new Point(width - 3,height - 1));
            list.Add(new Point(width - 6,height - 1));
            list.Add(new Point(width - 6,height - 0));
            //左下
            list.Add(new Point(6,height - 0));
            list.Add(new Point(6,height - 1));
            list.Add(new Point(3,height - 1));
            list.Add(new Point(3,height - 2));
            list.Add(new Point(2,height - 2));
            list.Add(new Point(2,height - 3));
            list.Add(new Point(1,height - 3));
            list.Add(new Point(1,height - 6));
            list.Add(new Point(0,height - 6));

            Point[] points = list.ToArray();

            GraphicsPath shape = new GraphicsPath();
            shape.AddPolygon(points);

            //将窗体的显示区域设为GraphicsPath的实例
            sender.Region = new System.Drawing.Region(shape);

            shape = null;
        }
    }
}